Formius.Validator_RegExp = $.inherit(Formius.Validator_Abstract, {
	_options: {
		compareFlags: 'gi'
	},
	
	_isInverse: function() {
		return ('inverse' in this._options && this._options['inverse']);
	},
	_isValid: function(value) {
		if (! 'compare' in this._options) {
			this._setCode('UNKNOWN_COMPARE');
			return false;
		}
		if ($.isArray(value)) {
			if (value.length == 1) {
				value = value[0];
			} else if (value.length == 0) {
				value = '';
			}
		}
		if ($.isArray(value)) {
			var result = false, self = this;
			$(value).each(function(i, val){
				result = result && self._testRegExp(val);
			});
			return result;
		}
		if (!this._testRegExp(value)) {
			this._setCode('INVALID');
			return false;
		}
		return true;
	},
	_testRegExp: function(value) {
		var re = new RegExp(this._options['compare'], this._options['compareFlags']);
		var result = re.test(value);
		return (this._isInverse()? !result: !!result);
	}
});